/**
 * @param {string} s
 * @return {string}
 */
var makeSmallestPalindrome = function (s) {
  let i = 0
  let j = s.length - 1
  let arr = []
  while (i <= j) {
    if (s.charAt(i) < s.charAt(j)) {
      arr[i] = s.charAt(i)
      arr[j] = s.charAt(i)
    } else {
      arr[i] = s.charAt(j)
      arr[j] = s.charAt(j)
    }
    i++
    j--
  }
  return arr.join('')
}
makeSmallestPalindrome("egcfe")